/*
 * @Author: cyq
 * @Date: 2023-06-29 20:06:17
 * @Last Modified by: cyq
 * @Last Modified time: 2023-06-29 20:38:00
 */

//@ts-nocheck
import { createStore } from "vuex";
import { BeasicType } from "@/interfase/commont";
import { Commit } from "@/interfase/store";

//读取modules文件夹中的内容，并通过require.context读取文件组成完整的 vuex modules

const modulecreate = function () {
  const modules: BeasicType.Data<Commit<string>> = {};
  const context = require.context("./module", true, /\.ts|js$/);
  const files = context.keys().map((key) => context(key));
  console.log(files);
  files.forEach((file) => {
    modules[file.default.name] = file.default;
  });
  console.log(modules);
  //实现文件的自动引入
  return modules;
};

export default createStore({
  modules: modulecreate(),
});
